package com.smmisia.article.controller;

import com.smmisia.article.entity.Banner;
import com.smmisia.article.service.BannerService;
import com.smmisia.common.Result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页轮播图
 * @author ：smmisia
 * @date ：Created in 2023/4/13 14:05
 * @description：轮播图
 * TODO 缺少权限
 */
@RestController
@Slf4j
@Tag(name = "首页轮播图")
public class bannerController {

    @Autowired
    private BannerService bannerService;

    /**
     * 显示首页轮播图
     */
    @GetMapping("/banner")
    @Operation(summary = "显示首页轮播图")
    public Result<List<Banner>> banner() {
        return bannerService.banner();
    }

    /**
     * 新增轮播图
     */
    @GetMapping("/add")
    @Operation(summary = "新增轮播图")
    public Result<Banner> add(@RequestParam(name = "url") String url) {
        return bannerService.add(url);
    }

    /**
     * 删除轮播图
     */
    @GetMapping("/delete")
    @Operation(summary = "删除轮播图")
    public Result<String> delete(@RequestParam(name = "id") Integer id) {
        return bannerService.delete(id);
    }
}